/**
 * 保存方法
 * @returns 
 */
function save() {
    var username = document.getElementById("username");
    var password = document.getElementById("password");
    var type = document.getElementById("type");
    var state = document.getElementById("state");
    if ("" == username.value || "" == password.value) {
        alert("账号或密码为空");
        return;
    }
    if (type.selectedIndex == 0) {
        alert("请选择运营商");
        return;
    }
    chrome.storage.sync.set({
        "GXUusername": username.value,
        "GXUpassword": password.value,
        "GXUtype": type[type.selectedIndex].value,
        "GXUstate": state.checked
    }, function () {
        alert("保存了");
    });
}
/**
 * 显示页面
 */
function showHome() {
    chrome.storage.sync.get({ "GXUusername": null, "GXUpassword": null, "GXUtype": null, "GXUstate": null }, function (n) {
        if (null != n.GXUusername && null != n.GXUpassword && null != n.GXUtype) {
            var username = document.getElementById("username");
            var password = document.getElementById("password");
            var type = document.getElementById("type");
            var state = document.getElementById("state");
            username.value = n.GXUusername;
            password.value = n.GXUpassword;
            type.value = n.GXUtype;
            if (n.GXUstate == false) {
                state.checked = false;
            } else {
                state.checked = true;
            }
        }

    });
}
window.onload = showHome;
var confirmBtn = document.getElementById("confirm");
confirmBtn.onclick = save;
